import json

my_json = """{"capabilities":{"firstMatch":[{}],"alwaysMatch":{"browserName":"谷歌浏览器","pageLoadStrategy":"normal","goog:chromeOptions":{"extensions":[],"args":[]}}}}"""
print(type(my_json))

# json字符串转为字典类型
my_dict = json.loads(my_json)
print(my_dict)
print(type(my_dict))
# 字典类型转为json字符串
my_str = json.dumps(my_dict, ensure_ascii=False)
print(my_str)
print(type(my_str))
# # 将json内容序列化到文档中
json.dump(my_dict, open('.\my_json.txt', 'a', encoding='utf-8'), ensure_ascii=False)
